package com.ylr.basic.framework.mq;

import com.ylr.basic.framework.service.RequestLogService;
import com.ylr.base.common.po.RequestLogPo;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-04-28 22:29:06
 * className: RequestLogListener
 * version: 1.0
 * description:
 */
@Component
@AllArgsConstructor
public class RequestLogListener {

    private static final Logger log = LoggerFactory.getLogger(RequestLogListener.class);

    private RequestLogService requestLogService;

    @RabbitListener(queues = "log.queue" )
    public void requestLogListener(RequestLogPo requestLogPo) {
        log.info("开始记录请求日志操作。{}", requestLogPo);

        requestLogService.saveRequestLog(requestLogPo);

        log.info("记录请求日志操作结束");
    }

}
